package com.gitee.neuray.security.wb.ribs.biz;

import com.gitee.neuray.security.common.biz.BaseBiz;
import com.gitee.neuray.security.common.msg.TableResultResponse;
import com.gitee.neuray.security.common.util.Query;
import com.gitee.neuray.security.common.util.UUIDUtils;
import com.gitee.neuray.security.wb.ribs.mapper.ClfMapper;
import com.gitee.neuray.security.wb.ribs.vo.ClfVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class ClfBiz extends BaseBiz<ClfMapper, ClfVo> {
  @Autowired private ClfMapper clfMapper;
  /**
   * 获取差旅费信息
   *
   * @param query
   * @return
   */
  public TableResultResponse getClfInfo(Query query) {
    Page<Object> result = PageHelper.startPage(query.getPageNo(), query.getPageSize());
    List<ClfVo> list = clfMapper.getClfInfo(query);
    return new TableResultResponse(
        result.getPageSize(), result.getPageNum(), result.getPages(), result.getTotal(), list);
  }

  /**
   * 填报差旅费
   *
   * @param clfVo
   */
  public void insertClf(ClfVo clfVo) {
    String id = UUIDUtils.generateShortUuid();
    clfVo.setId(id);
    super.insertSelective(clfVo);
  }

  /**
   * 差旅费修改
   *
   * @param clfVo
   */
  public void updClf(ClfVo clfVo) {

    super.updateSelectiveById(clfVo);
  }

  /** 删除差旅费 */
  public void delClf(String id) {
    super.deleteById(id);
  }

  @Override
  protected String getPageName() {
    return null;
  }

  public List<ClfVo> queryClf(ClfVo clfVo){

    return clfMapper.queryClf(clfVo);

  }
}
